package com.rupertjones.globalcron.server.dao;

import com.rupertjones.globalcron.common.domain.Role;
import org.hibernate.Criteria;
import org.springframework.stereotype.Repository;

import static org.hibernate.criterion.Restrictions.eq;

/**
 * <p>&copy Rupert Jones 2011,2012</p>
 *
 * @author rup
 */
@Repository
public class RoleDAO extends AbstractHibernateDAO<Role> {
    public RoleDAO() {
        super(Role.class);
    }

    public Role findByName(String roleName) {
        Criteria criteria = getCriteria().add(eq("name", roleName));
        return (Role) criteria.uniqueResult();
    }
}
